package com.youngjun.user.api.admin;

import com.youngjun.common.mybatis.web.Response;
import com.youngjun.user.pojo.dto.RoleDTO;
import com.youngjun.user.pojo.dto.query.RoleQueryDTO;
import com.youngjun.user.pojo.vo.RoleVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Api(tags = "角色管理")
@FeignClient(
        name = "${ums.api.name:ums-service}",
        contextId = "roleRestApi",
        url  = "${ums.api.url:http://127.0.0.1:8080}",
        path = "/role"
)
public interface IRoleRestApi {

    /**
     * 根据当前角色权限查询角色信息
     */
    @ApiOperation(value="根据当前角色权限删除角色信息")
    @RequestMapping(method = RequestMethod.GET, path = "/query_list_by_current_role")
    Response<List<RoleVO>> queryListByCurrentRole();

    /**
     * 根据当前角色权限创建角色信息
     * @param dto 角色信息
     */
    @ApiOperation(value="根据当前角色权限删除角色信息")
    @RequestMapping(method = RequestMethod.POST, path = "/create_by_current_role")
    Response<RoleVO> createByCurrentRole(@RequestBody @Valid RoleDTO dto);

    /**
     * 根据当前角色权限修改角色信息
     * @param dto 角色信息
     */
    @ApiOperation(value="根据当前角色权限删除角色信息")
    @RequestMapping(method = RequestMethod.DELETE, path = "/modify_by_current_role")
    Response<RoleVO> modifyByCurrentRole(@RequestBody @Valid RoleDTO dto);

    /**
     * 根据当前角色权限删除角色信息
     * @param id 角色id
     */
    @ApiOperation(value="根据当前角色权限删除角色信息")
    @RequestMapping(method = RequestMethod.DELETE, path = "/delete_by_current_role")
    Response<Void> deleteByCurrentRole(@RequestParam("id") Long id);


    @ApiOperation(value="根据组织id查询角色信息")
    @RequestMapping(method = RequestMethod.POST, path = "/query_list_by_current_organization")
    Response<List<RoleVO>> queryListByCurrentOrganization(@RequestBody RoleQueryDTO dto);

    @ApiOperation(value="查询角色信息")
    @RequestMapping(method = RequestMethod.POST, path = "/query_list")
    Response<List<RoleVO>> queryList(@RequestBody RoleQueryDTO dto);

    @ApiOperation(value="创建角色信息")
    @RequestMapping(value = "/create",method = RequestMethod.POST)
    Response<RoleVO> create(@RequestBody @Valid RoleDTO dto);

    @ApiOperation(value="修改角色信息")
    @RequestMapping(value = "/modify",method = RequestMethod.PUT)
    Response<RoleVO> modify(@RequestBody @Valid RoleDTO dto);

    @ApiOperation(value="删除角色信息")
    @RequestMapping(value = "/delete",method = RequestMethod.DELETE)
    Response<Void> delete(@RequestParam("id") Long id);


}